Freshers / Beginner level questions
Freshers / Beginner level questions & answers
Ques 1. Explain the box model in CSS.
The box model consists of content, padding, border, and margin. It defines the spacing and dimensions of an element.
Example:
div {
width: 200px;
padding: 20px;
border: 2px solid black;
margin: 10px;
}
Ques 2. What is the difference between 'GET' and 'POST' HTTP methods?
'GET' is used to request data from a specified resource, while 'POST' is used to submit data to be processed to a specified resource.
Ques 3. Explain the purpose of the 'box-sizing' property in CSS.
The 'box-sizing' property defines how the width and height of an element are calculated, including the padding and border, or excluding them.
Example:
div {
box-sizing: border-box;
}
Ques 4. What is the purpose of the 'cookie' in web development?
Cookies are small pieces of data stored on the client's machine, used to store user information and maintain state between HTTP requests.
Example:
document.cookie = 'username=John; expires=Thu, 18 Dec 2024 12:00:00 UTC; path=/';
Ques 5. What is the difference between 'localStorage' and 'sessionStorage'?
'localStorage' stores data with no expiration time, while 'sessionStorage' stores data for the duration of the page session.
Ques 6. What is the role of the 'DOCTYPE' declaration in HTML?
The 'DOCTYPE' declaration defines the document type and version of HTML or XHTML, ensuring proper rendering in web browsers.
Example:
Ques 7. What is the 'CSS Box Model'?
The CSS Box Model is a design and layout concept that consists of content, padding, border, and margin, defining the space around and within an HTML element.
Ques 8. Explain the difference between 'localStorage' and 'sessionStorage'.
'localStorage' persists even when the browser is closed and reopened, while 'sessionStorage' data is only available for the duration of the page session.
Ques 9. What is the 'DRY' principle in software development?
DRY (Don't Repeat Yourself) is a software development principle advocating for reducing redundancy by reusing code and avoiding duplication.
Ques 10. What is the role of the 'meta' tag with the 'charset' attribute in HTML?
The 'meta' tag with the 'charset' attribute specifies the character encoding for the HTML document, ensuring proper text rendering.
Example:
Ques 11. What is the 'event.preventDefault()' method in JavaScript used for?
'event.preventDefault()' is used to prevent the default behavior associated with an event, such as preventing a form submission or a link from navigating.
Example:
document.getElementById('myForm').addEventListener('submit', function(event) {
event.preventDefault();
// additional handling code
});
Most helpful rated by users: